﻿(function () {
    try {
        //#region Static

        var _Class = function(){};
        _Class.Base = function(/*options, Instance*/) {
            try {
//                Instance = Common.ExtendOptions(Instance, options);

//                if (!options)
//                    options = {};

                //#region Properties

//                if(!Instance.Events)
//                    Instance.Events = {};
//                if(!Instance.Events.onError)
//                    Instance.Events.onError = [function(Instance, error) { Common.ShowError(error); }];

                Instance = { Public: {} };

                Instance.Base = function(){};
                Instance.Base.Public = {};
                Instance.Base.Public =
                Instance.Base.GetHerency =  function() { 
                Instance.Base.Public =
                Instance.Base.GetHerency =  function() { 
                    try {
                        return Instance.Base;
                    }
                    catch (Error) { Common.ShowError(Error); }
                };
                Instance.Base.Public.Constructor = 
                Instance.Base.Constructor = function(/*options*/) {
                    try {
                        var instance = new Instance.Base(/*options*/);

                        /* Public. */
                        Common.ExtendObject(classBase.Public, this);
                    }
                    catch (Error) { Common.ShowError(Error); }
                };

                Instance.Public.Base = Instance.Base;

                //#endregion

                //#region Methods


                //#region Events

//                Instance.Combobox_Selected = function(event, ui) {
//                    try {
//                        Instance.ID = ui.item.id;
//                        Instance.Name = $.trim(ui.item.value).toUpperCase();

//                        Instance.FireEventSelected(event, ui);
//                    }
//                    catch (Error) { Instance.FireEventError(Error); }
//                };

                //#endregion

                //#region Own Events

//                Instance.FireEventError = function(error) {
//                    try
//                    {
//                        for(var handlerIndex = 0; handlerIndex < Instance.Events.onError.length; handlerIndex++)
//                            Instance.Events.onError[handlerIndex](Instance, error);
//                    }
//                    catch(Error) { Instance.FireEventError(Error); }
//                }

                //#endregion

                //#endregion

                return Instance;
            }
            catch(Error) { Common.ShowError(Error); }
            return null;
        };
        _Class.Constructor = function(/*options*/) {
            try {
                var instance = new _Class.Base(/*options*/);

                /* Public. */
                Common.ExtendObject(classBase.Public, this);
            }
            catch (Error) { Common.ShowError(Error); }
        };
//        _Class.GetHerency = function() {
//            try {
//                return _Class.Base;
//            }
//            catch (Error) { Common.ShowError(Error); }
//        };

        //#endregion

        window.Class = _Class.Constructor;
    }
    catch (Error) { Common.ShowError(Error); }
})();



//    _Grid.GridBase = function(options, Instance) {
//        try {

//            Instance = _Grid.ExtendOptions(options, Instance);

//            if (!options)
//                options = {};

//            if(!Instance.ExtAttributes)
//                Instance.ExtAttributes = {};
//            if(!Instance.ExtAttributes.GridOptions)
//                Instance.ExtAttributes.GridOptions = {};
//            if(!Instance.ExtAttributes.GridOptions.URL)
//                Instance.ExtAttributes.GridOptions.URL = Global.DALServiceURL;
//            else
//                Instance.ExtAttributes.GridOptions.URL = Trim(Instance.ExtAttributes.GridOptions.URL);
//            if(!Instance.ExtAttributes.GridOptions.DatabaseParameters)
//                Instance.ExtAttributes.GridOptions.DatabaseParameters = {};
//            if(!Instance.ExtAttributes.GridOptions.DatabaseParameters.ConnectionStringName)
//                Instance.ExtAttributes.GridOptions.DatabaseParameters.ConnectionStringName = Global.ConnectionStringNames.SDIMes;
//            else
//                Instance.ExtAttributes.GridOptions.DatabaseParameters.ConnectionStringName = Trim(Instance.ExtAttributes.GridOptions.DatabaseParameters.ConnectionStringName);
//            if(!Instance.ExtAttributes.GridOptions.DatabaseParameters.Procedure)
//                Instance.ExtAttributes.GridOptions.DatabaseParameters.Procedure = "";
//            else
//                Instance.ExtAttributes.GridOptions.DatabaseParameters.Procedure = Trim(Instance.ExtAttributes.GridOptions.DatabaseParameters.Procedure);
//            if(!Instance.ExtAttributes.GridOptions.Events)
//                Instance.ExtAttributes.GridOptions.Events = {};
//            if(!Instance.ExtAttributes.GridOptions.Events.onError)
//                Instance.ExtAttributes.GridOptions.Events.onError = ShowError;

//            Instance.Grid = null;

//            return Instance;
//        }
//        catch(Error) { ShowError(Error); }
//        return null;
//    }
//    _Grid.GridIGBase = function(options, Instance) {
//        try {
//            Instance = _Grid.GridBase(options, Instance);

//            if (!options)
//                options = {};

//            Instance.Initialize = function (container) {
//                try {
//                    Instance.Grid = new IndustrialGrid(container, Instance.ExtAttributes.GridOptions);

//                    Instance.Grid.ExtAttributes = Instance.ExtAttributes;
//                }
//                catch(Error){ ShowError(Error); }
//            }

//            if(!Instance.ExtAttributes.GridOptions.Export)
//                Instance.ExtAttributes.GridOptions.Export = {};
//            if(!Instance.ExtAttributes.GridOptions.Export.OutputFileName)
//                Instance.ExtAttributes.GridOptions.Export.OutputFileName = "";
//            else
//                Instance.ExtAttributes.GridOptions.Export.OutputFileName = Trim(Instance.ExtAttributes.GridOptions.Export.OutputFileName);
//            if(!Instance.ExtAttributes.GridOptions.Export.Source)
//                Instance.ExtAttributes.GridOptions.Export.Source = "SERVERCURRENTVIEW";
//            else
//                Instance.ExtAttributes.GridOptions.Export.Source = Trim(Instance.ExtAttributes.GridOptions.Export.Source);
//            if(!Instance.ExtAttributes.GridOptions.View)
//                Instance.ExtAttributes.GridOptions.View = {};
//            if((Instance.ExtAttributes.GridOptions.View.Legend == undefined) || (Instance.ExtAttributes.GridOptions.View.Legend == null))
//                Instance.ExtAttributes.GridOptions.View.Legend = false;
//            if(!Instance.ExtAttributes.GridOptions.View.Title)
//                Instance.ExtAttributes.GridOptions.View.Title = "";
//            else
//                Instance.ExtAttributes.GridOptions.View.Title = Trim(Instance.ExtAttributes.GridOptions.View.Title);

//            return Instance;
//        }
//        catch(Error) { ShowError(Error); }
//        return null;
//    }